package com.babai.service.base;

import com.babai.entity.platform.BaseEntity;
import com.babai.service.EntityHandler;
import com.babai.dao.BaseRepository;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public interface BaseService<T extends BaseEntity, ID extends Serializable> {

    BaseRepository getRepository();

    T save(T t);

    void save(Iterable<T> entities);

    T saveOrUpdate(T t);

    T findById(ID id);

    void findById(ID id, EntityHandler<T> entityHandler);

    void deleteById(ID id);

    void delete(T t);

    void deleteAll(Iterable<ID> ids);

    List<T> findAll();

    List<T> findAll(Iterable<ID> ids);

    void findAll(Iterable<ID> ids, EntityHandler<T> entityHandler);

    List<T> findAll(Sort sort);

    Page<T> findAll(Pageable pageable);

    Page<T> findAll(Pageable pageable, Example<T> example);

    void execute(String sql, Object... args);

    List<Object[]> query(String sql, Object... args);

    List<Object[]> queryPage(String sql, Map<String, Object> paramMap, int pageNumber, int pageSize);
}